<?php
/**
 * Created by PhpStorm.
 * Vercode: ciwei
 * Date: 2017/11/28
 * Time: 11:10
 */
namespace app\index\validate;

use \think\Validate;

class User extends Validate
{
    protected $rule = [
        'nickname'  =>  'require|unique:user|length:2,6',
        'email' =>  'require|email|unique:user',
        'password' => 'require|length:6,18',
        'repassword'=>'require|confirm:password',
        'city' => 'length:2,18',
        'sign' =>'length:6,50'
    ];

    protected $message = [
        'nickname.require' => '名称不能为空',
        'nickname.length'  => '名称为2-6个字符',
        'nickname.unique'  => '昵称已存在',
        'email.email'  => '邮箱格式错误',
        'email.unique' => '邮箱已存在',
        'password.require'=>'密码不能为空',
        'password.length'=>'密码长度不对',
        'repassword'   => '两次密码不一致',
        'city' => '城市格式不对',
        'sign' => '签名为6-50个字符'
    ];
    protected $scene = [
        'login'  =>  [
            'email'=>'require|email',
            'password' => 'require|length:6,18',
            ],
        'edit' =>[
            'city',
            'sign',
            'nickname'  =>  'length:2,6',
            'email'=>'email',
            'password' => 'length:6,18',
            'repassword'=>'confirm:password',
        ]
    ];
}